<clr-modal [(clrModalOpen)]="modalOpened">
  <h3 class="modal-title">{{title}}</h3>
  <div class="modal-body">
    <form #ngForm="ngForm" clrForm clrLayout="horizontal">
      <section class="form-block">
        <div class="clr-form-control clr-row">
          <label class="clr-control-label required">
            {{'TITLE.NAME' | translate}}
          </label>
          <div class="clr-control-container clr-col-md-10 clr-col-12"
            [class.clr-error]="name.invalid && (name.dirty || name.touched)">
            <div class="clr-input-wrapper">
              <span *ngIf="app && actionType==0 && nameGenerateRuleConfig=='join'">{{app.name}}-</span>
              <input type="text" class="clr-input" id="name" [(ngModel)]="resource.name" name="name" required placeholder="英文小写"
                [readonly]="actionType==1" maxlength="64" pattern="[a-z]([-a-z0-9]*[a-z0-9])?" (keyup)='checkNameValid()' #name="ngModel">
            </div>
            <span *ngIf="name.invalid && (name.dirty || name.touched)"
              class="clr-subtext">{{'RULE.REGEXT' | translate}}[a-z]([-a-z0-9]*[a-z0-9])?</span>
          </div>
        </div>
        <clr-checkbox-container>
          <label class="required">{{'TITLE.CLUSTER' | translate}}</label>
          <clr-checkbox-wrapper *ngFor="let cluster of clusters" style="display: inline-block;">
            <input clrCheckbox [(ngModel)]="clusterMetas[cluster.name].checked" type="checkbox" id="{{cluster.name}}-check" name="{{cluster.name}}-check">
            <label>{{cluster.name}}</label>
          </clr-checkbox-wrapper>
          <clr-control-helper>
            <span class="warning-text" *ngIf="!clusters || clusters && clusters.length === 0"></span>
          </clr-control-helper>
          <clr-control-error>{{'ERROR.CLUSTER' | translate}}</clr-control-error>
        </clr-checkbox-container>
        <clr-textarea-container>
          <label>{{'TITLE.DESCRIPTION' | translate}}</label>
          <textarea clrTextarea id="description" [(ngModel)]="resource.description" name="description" rows="3">
                    </textarea>
        </clr-textarea-container>
      </section>
    </form>
  </div>
  <div class="modal-footer" style="padding-right: 5%">
    <button type="button" class="btn btn-outline" (click)="onCancel()">取消</button>
    <button type="button" class="btn btn-primary" [disabled]="!isValid" (click)="onSubmit()">提交</button>
  </div>
</clr-modal>

